package com.dp.springsourcecodeanalysis.web.converters;

import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

import com.dp.springsourcecodeanalysis.web.dto.GoodsSkcCustomParseDTO;

/**
 * 自定义数据解析方式
 *
 * @author shala/沙拉
 * @date 2021/12/31 17:35
 */

public class GoodsSkcConverters implements Converter<String, GoodsSkcCustomParseDTO> {

    @Override
    public GoodsSkcCustomParseDTO convert(String source) {
        if (StringUtils.isEmpty(source)) {
            return null;
        }
        GoodsSkcCustomParseDTO dto = new GoodsSkcCustomParseDTO();
        String[] split = source.split("&");
        dto.setGoodsSkc(split[0]);
        dto.setGoodsSkcCat(split[1]);
        return dto;
    }

}
